# encoding: utf-8
import time
import commands
import os

print "开始执行脚本"

#创建相应的文件夹
dt = time.strftime('%Y%m%d',time.localtime())
dir_path = './deploy/' + dt
if (os.path.exists(dir_path)):
  (status,output) = commands.getstatusoutput('rm -fr ' + dir_path)
(status,output) = commands.getstatusoutput('mkdir ' + dir_path)
#复制相应的文件到目标目录
(status,output) = commands.getstatusoutput('cp -fr --parent lib ' + dir_path)
(status,output) = commands.getstatusoutput('cp -fr --parent models ' + dir_path)
(status,output) = commands.getstatusoutput('cp -fr --parent services ' + dir_path)
(status,output) = commands.getstatusoutput('cp -fr --parent controllers ' + dir_path)
(status,output) = commands.getstatusoutput('cp -fr --parent app.js ' + dir_path)
(status,output) = commands.getstatusoutput('cp -fr --parent urls.js ' + dir_path)
(status,output) = commands.getstatusoutput('cp -fr --parent node_modules/gfportal ' + dir_path)

#生成压缩包

(status,output) = commands.getstatusoutput('rm -f  ' + dir_path + ".zip");
(status,output) = commands.getstatusoutput('zip -r ' + dir_path + ".zip " + dir_path);
print status
print output
print "执行完成"
